package com.prs.crm.action.oa.schedule;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.action.ReportAction;
import com.prs.crm.domain.assets.AssetsRegister;
import com.prs.crm.domain.oa.schedule.MyThings;
import com.prs.crm.domain.oa.schedule.OthersThings;
import com.prs.crm.report.ExportConfig;
import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;

public class ThingsReportAction extends ReportAction{

	private static final long serialVersionUID = 1L;
	/****我的日程计划导出****/
	@Action(value = "reportMyThings", results = { @Result(name = "success", type = "stream", params = {
			"contentType", "${contentType}", "inputName", "inputStream",
			"bufferSize", "1024", "contentDisposition",
			"filename=${outfileName}" }) })
	public String reportMyThings() {
		ReportTable table = new ReportTable("工作日程");
		table.addCell(new ReportCell("开始时间", "cs_beginTime"));
		table.addCell(new ReportCell("结束时间", "cs_overTime"));
		table.addCell(new ReportCell("工作内容", "mt_thingsContext"));
		table.addCell(new ReportCell("重要度", "mt_importance"));
		table.addCell(new ReportCell("状态", "mt_state"));
		table.addCell(new ReportCell("分配人 ", "recorder.resume.name"));
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				MyThings.class).add(Restrictions.eq("mt_type", "普通日程"));
		this.setOutFilePath(this.getReportService().exportAlreadyDistribution(
				criteria, table, new ExportConfig(), this.getExportType()));
		return SUCCESS;
	}
	/****他人日程计划导出****/
	@Action(value = "reportOthersThings", results = { @Result(name = "success", type = "stream", params = {
			"contentType", "${contentType}", "inputName", "inputStream",
			"bufferSize", "1024", "contentDisposition",
			"filename=${outfileName}" }) })
	public String reportOthersThings() {
		ReportTable table = new ReportTable("他人工作日程");
		table.addCell(new ReportCell("事务所属人", "receivePerson.resume.name"));
		table.addCell(new ReportCell("开始时间", "cs_beginTime"));
		table.addCell(new ReportCell("结束时间", "cs_overTime"));
		table.addCell(new ReportCell("工作内容", "ot_thingsContext"));
		table.addCell(new ReportCell("重要度", "ot_importance"));
		table.addCell(new ReportCell("状态", "ot_state"));
		table.addCell(new ReportCell("分配人 ", "recorder.resume.name"));
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				OthersThings.class).add(Restrictions.eq("ot_type", "普通日程"));
		this.setOutFilePath(this.getReportService().exportAlreadyDistribution(
				criteria, table, new ExportConfig(), this.getExportType()));
		return SUCCESS;
	}
}
